package com.example.tys.baseapplication.DataModel.data;

import com.example.tys.baseapplication.DataModel.greendao.GreenDaoFactory;

/**
 *
 * @author tys
 * @date 2017/9/30
 */

public class DataServer {

    private static AbstractDataFactory daoFactory;

    public static void setDaoFactory(AbstractDataFactory daoFactory) {
        DataServer.daoFactory = null;
        DataServer.daoFactory = daoFactory;
    }

    public static <T> IDaoOperation<?> getDaoOperation(Class<T> dataType) {
        if (daoFactory == null) {
            synchronized (DataServer.class) {
                if (null == daoFactory) {
                    daoFactory = new GreenDaoFactory();
                }
            }
        }
        return daoFactory.getDaoOperation(dataType);
    }


}
